import {
  addTag,
  queryList,
  deleteTag,
  updateTag,
} from '@/services/sensitiveData/tags';

export default {
  namespace: 'tags',
  state: {
    // 列表查询
    dataqueryList: {
      dataList: [],
      pageNum: 0,
      pageSize: 0,
      totalCount: 0,
    },

  },

  effects: {
    //列表查询
    *queryList({ payload }, { call, put }) {
      const response = yield call(queryList, payload);
      yield put({
        type: 'savequeryList',
        payload: response.data || {
          dataList: [],
          pageNum: 0,
          pageSize: 0,
          totalCount: 0,
        },
      });
    },
    //新增
    *addTag({ payload }, { call, put }) {
      const response = yield call(addTag, payload);
      return response;
    },


    //删除
    *deleteTag({ payload }, { call, put }) {
      const response = yield call(deleteTag, payload);
      return response;
    },

    *updateTag({ payload }, { call, put }) {
      const response = yield call(updateTag, payload);
      return response;
    },
  },
  reducers: {
    savequeryList(state, { payload }) {
      return {
        ...state,
        dataqueryList: payload,
      };
    },
  },
};
